package com.itypd.pojo;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/*
 * @Description:
 * @Athor: GongMingwei
 * @version: v1.0
 */
public class LockTestObj {
    private int i = 0;
    private Lock lock = new ReentrantLock();
    public int getI(){
        return i;
    }
    public void increase(){
        if(lock.tryLock()){
            lock.lock();
            if(i < 1000){
                System.out.println(i++);
            }
            lock.unlock();
        }
    }
}
